<?php
// +----------------------------------------------------------------------
// | Qbt CMS Plugin
// +----------------------------------------------------------------------
// | Copyright (c) 2012-2018 http://www.qbt8.com All rights reserved.
// +----------------------------------------------------------------------
// | Author: 黄老邪 <develop02@qbt8.com>
// +----------------------------------------------------------------------
namespace plugins\qbt_app_update;
use cmf\lib\Plugin;
use think\Config;
use think\db;

class QbtAppUpdatePlugin extends Plugin
{

    public $info = [
        'name'        => 'QbtAppUpdate',
        'title'       => 'app更新',
        'description' => '千佰特app更新功能',
        'status'      => 1,
        'author'      => '千佰特',
        'version'     => '1.0',
        'demo_url'    => 'http://www.qbt8.com',
        'author_url'  => 'http://www.qbt8.com'
    ];

    public $hasAdmin = 1;//插件是否有后台管理界面

    // 插件安装
    public function install()
    {
        $config = Config::get('database');
        Db::query("
            CREATE TABLE IF NOT EXISTS `{$config['prefix']}app_update` (
            `id` int(11) NOT NULL AUTO_INCREMENT,
              `app_name` varchar (20) DEFAULT NULL COMMENT 'app名称',
              `packge_name` varchar (255) DEFAULT NULL COMMENT 'app包名',
              `version_name` varchar (20) DEFAULT NULL COMMENT '版本名称',
              `version_code` varchar(20) DEFAULT NULL COMMENT '版本号',
              `apk_url` varchar(255) DEFAULT NULL COMMENT 'apk链接',
              `iden` varchar(255) DEFAULT NULL COMMENT 'api标识',
              `upgrade_point` varchar(255) DEFAULT NULL COMMENT '升级备注',
              `type` tinyint(2) DEFAULT NULL COMMENT '1为app2为ios3为小程序',
              `force` tinyint(2) NOT NULL,
              `create_time` int(11) DEFAULT NULL,
              PRIMARY KEY (`id`)
            )
        ");
        return true;
    }

    // 插件卸载
    public function uninstall()
    {
        $config = Config::get('database');
        Db::query("DROP TABLE `{$config['prefix']}app_update`");
        return true;
    }


}